{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1. 0. 1.]\n",
      " [1. 0. 0.]\n",
      " [0. 0. 1.]]\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "os.chdir(\"/home/lab466/pythons/pyDesignML35/ch07\")\n",
    "# %run \n",
    "\n",
    "#P142 Binarizer module.\n",
    "from sklearn.preprocessing import Binarizer\n",
    "from random import randint\n",
    "bin=Binarizer(5)\n",
    "#X=[randint(0,10) for b in range(1,10)]\n",
    "X = [[ 10., 3.,  8.],\n",
    "     [ 7.,  0.,  4.],\n",
    "     [ 0.,  1., 6.]]\n",
    "X\n",
    "print(bin.transform(X))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 1.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bin = Binarizer(threshold=5)\n",
    "bin.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 1.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#  二值化–特征的二值化\n",
    "# 特征的二值化是指将数值型的特征数据转换成布尔类型的值。可以使用实用类Binarizer\n",
    "# 默认是根据0来二值化，大于0的都标记为1，小于等于0的都标记为0。\n",
    "\n",
    "from sklearn import preprocessing\n",
    "import numpy as np\n",
    " \n",
    "# 创建一组特征数据，每一行表示一个样本，每一列表示一个特征\n",
    "x = np.array([[1., -1., 2.],\n",
    "              [2., 0., 0.],\n",
    "              [0., 1., -1.]])\n",
    " \n",
    "binarizer = preprocessing.Binarizer().fit(x)\n",
    "binarizer.transform(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0., 1., 0., 0., 0., 0., 1.]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#独热编码，在英文文献中称做 one-hot code, 直观来说就是有多少个状态就有多少比特，\n",
    "#而且只有一个比特为1，其他全为0的一种码制\n",
    "#https://blog.csdn.net/weixin_40807247/article/details/82793220\n",
    "from sklearn import preprocessing\n",
    "enc = preprocessing.OneHotEncoder()\n",
    "enc.fit([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]])    # fit来学习编码\n",
    "enc.transform([[0, 1, 3]]).toarray()    # 进行编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n数据矩阵[[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]]是4*3，即4个数据，3个特征维度。\\n0 0 3\\n1 1 0\\n0 2 1\\n1 0 2\\n观察左边的数据矩阵，第一列为第一个特征维度，有两种取值0\\x01. 所以对应编码方式为10 、01\\n同理，第二列为第二个特征维度，有三种取值0\\x01\\x02，所以对应编码方式为100、010、001\\n同理，第三列为第三个特征维度，有四中取值0\\x01\\x02\\x03，所以对应编码方式为1000、0100、0010、0001\\n再来看要进行编码的参数[0 , 1,\\xa0 3]， 0作为第一个特征编码为10,\\xa0 1作为第二个特征编码为010， 3作为第三个特征编码为0001.\\xa0 故此编码结果为 10  010  0001\\xa0\\n'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "数据矩阵[[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]]是4*3，即4个数据，3个特征维度。\n",
    "0 0 3\n",
    "1 1 0\n",
    "0 2 1\n",
    "1 0 2\n",
    "观察左边的数据矩阵，第一列为第一个特征维度，有两种取值0\\1. 所以对应编码方式为10 、01\n",
    "同理，第二列为第二个特征维度，有三种取值0\\1\\2，所以对应编码方式为100、010、001\n",
    "同理，第三列为第三个特征维度，有四中取值0\\1\\2\\3，所以对应编码方式为1000、0100、0010、0001\n",
    "再来看要进行编码的参数[0 , 1,  3]， 0作为第一个特征编码为10,  1作为第二个特征编码为010， 3作为第三个特征编码为0001.  故此编码结果为 10  010  0001 \n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 1., 0., 0., 1., 1., 0., 0.]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#P143  OneHotEncoder\n",
    "from sklearn import preprocessing\n",
    "enc = preprocessing.OneHotEncoder()\n",
    "enc.fit([[1,2,0], [1, 1, 0], [0, 2, 1], [1, 0, 2]])    # fit来学习编码\n",
    "enc.transform([[1, 2, 0]]).toarray()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([[1.0, 2.0), [2.0, 3.0), [3.0, 4.003), [3.0, 4.003)]\n",
      "Categories (3, interval[float64]): [[1.0, 2.0) < [2.0, 3.0) < [3.0, 4.003)], array([1.   , 2.   , 3.   , 4.003]))\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[(18, 25], (18, 25], (18, 25], (25, 35], (18, 25], ..., (25, 35], (60, 100], (35, 60], (35, 60], (25, 35]]\n",
       "Length: 12\n",
       "Categories (4, interval[int64]): [(18, 25] < (25, 35] < (35, 60] < (60, 100]]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#P144   Pandas cut and qcut\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "print(pd.cut(np.array([1,2,3,4]), 3, retbins = True, right = False))\n",
    "#Age Sample\n",
    "ages = [20, 22,25,27,21,23,37,31,61,45,41,32]\n",
    "bins = [18, 25, 35, 60, 100]\n",
    "cats = pd.cut(ages, bins)\n",
    "cats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lab466/anaconda3/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
      "  \"This module will be removed in 0.20.\", DeprecationWarning)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAERCAYAAAB/4wAeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucTfX+x/HXB8OQSwwhOpWDcTlG7kSOe6ikwkmlKKFD\nJ3JXCtXpJqVExy+S43IqnUxS7kS55X6/5HaMUmOUQTOa4fP7Yy+ZmeayZ9qz1957Ps/HYx7WXvPd\na733mm199netvb5LVBVjjDHmsnxuBzDGGBNYrDAYY4xJxQqDMcaYVKwwGGOMScUKgzHGmFSsMBhj\njEnFCkMQEpExIvKLiJwWkRMiMjiX1jNMRIblxrKDiYg0FZFoP69zhoj09Oc6c4OIvCUi9/pgOfeK\nyFu+yGSyJnYdQ/ARkTFAuKqOEJFKwHqgrapudzdZcBORo0ALVT3qchREZAawSlVnuLDuFsAYVW3h\nwrpVVcXf6zWpWY8hyKnqYTyFIdLtLMaY0GCFIciJyJ+A+sB+53EvEfnWOcT0aIp294vIERH5QUSG\nppifbnvnd2Oc3snlx81FZFGKxxNFpI8z3VFE9ojI92meM0NEHhOR6SJy0IvX005E9jt5RjnzWojI\nThH52sk/NkX7bK1XRB4VkeMiclJEhjvz/iEip4DrgC0ickpErkrxnBYisipNzqMi8r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wAckZGXOhiKwWkfcyaVdGRFY6o8xOduaVFZFFTk8gy/GTnLF0igMJznfAVzo9iaHO7yOdETq/\nEZGnUjzvBhGZkeLxEjxDMHwkIq9n0i5aRCo60/NE5E8iUtXpwWwSkQe92ES/jaYrIi2c17rR6bFE\nishXQB2nd/Gg066Ts502ikhtL9Zh8igrDCZQPOXsGCc7jysA/8JztWYlESmbwfOaA7ucUWZXiUg+\nPEMh/MfpCdwpIhGZrPcjYA2esXRWA68CzwCNgQ7OiJy3A/9V1QZAhuPtqGo7PCOadlXVQZms82Og\nvYiEASVU9X/AK8AY4GZgeCbDIud3DqUdw9PL+gW4BuiK56LHvqq63+lVbHV6YDOd7fIGcCvQG3g2\nk3wmjwvJMfxNUHpBVWeleJwI9HB+rsZz5Wp6vgBaiMhnwDeqeklEIoEmzjH2osC1QFwGz++qqilH\npawOrHOWsxGoBvwbeMlZx8KcvbxUPgWm4Ckyl0e8rAqMBRTIj+c1/5TOcy+qagsRWQTsdOblByYD\nJ8h4O5XBM5BatPP4wh98DSaEWY/BBKpHgfnAfcD5TNo1Beaq6u1AOxH5M55B5EaoagtgPOnvYDOy\nB2jsfGJvgGdkzlbAS0AnPJ/mwzJ5fgJwVWYrUNWfnck7gHnO9AGgp5P5HbIeIvo1YLAzPRbPuY20\n52byw2+HymKddbRxXocvCpwJUVYYTKBaCjzFlcG+rs2g3UHgFWdsoB/xHGJ5CRgqIuvx7AhPZmO9\nw4DngA3AIlXdB3yLp9ewyZmXlMnzZwLTnPMRGX16B8/ra6Sqlwe5G+E8bxNwnapmVgxR1aVANRGp\nAHzmZBuN5yYsl/3HGSfofVW9BLwArAa+xFMojEmXjZVkjDEmFesxGGOMScUKgzHGmFSsMBhjjEnF\nCoMxxphUrDAYY4xJxQqDMcaYVP4fpun7odNd010AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7eff819718d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#P146  ROC \n",
    "# %run rocDemo.py\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import svm, datasets\n",
    "from sklearn.metrics import roc_curve, auc\n",
    "from sklearn.cross_validation import train_test_split\n",
    "from sklearn.preprocessing import label_binarize\n",
    "from sklearn.multiclass import OneVsRestClassifier\n",
    "\n",
    "X, y = datasets.make_classification(n_samples=100,n_classes=3,n_features=5, n_informative=3, n_redundant=0,random_state=42)\n",
    "# Binarize the output\n",
    "y = label_binarize(y, classes=[0, 1, 2])\n",
    "n_classes = y.shape[1]\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.5)\n",
    "classifier = OneVsRestClassifier(svm.SVC(kernel='linear', probability=True, ))\n",
    "y_score = classifier.fit(X_train, y_train).decision_function(X_test)\n",
    "fpr, tpr, _ = roc_curve(y_test[:,0], y_score[:,0]) \n",
    "roc_auc = auc(fpr, tpr)\n",
    "plt.figure()\n",
    "plt.plot(fpr, tpr, label='ROC AUC %0.2f' % roc_auc)\n",
    "plt.plot([0, 1], [0, 1], 'k--')\n",
    "plt.xlim([0.0, 1.0])\n",
    "plt.ylim([0.0, 1.05])\n",
    "plt.xlabel('False Positive Rate')\n",
    "plt.ylabel('True Positive Rate')\n",
    "plt.title('Receiver operating characteristic')\n",
    "plt.legend(loc=\"best\")\n",
    "plt.show()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1.  3. ]\n",
      " [4.  4.5]\n",
      " [5.  6. ]]\n"
     ]
    }
   ],
   "source": [
    "#P148  Imputer\n",
    "from sklearn.preprocessing import Binarizer, Imputer, OneHotEncoder\n",
    "imp = Imputer(missing_values='NaN', strategy='mean', axis=0)\n",
    "print(imp.fit_transform([[1, 3], [4, np.nan], [5, 6]]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0 1 2]\n",
      " [3 4 5]\n",
      " [6 7 8]]\n",
      "[[ 1.  0.  1.  2.  0.  0.  0.  1.  2.  4.]\n",
      " [ 1.  3.  4.  5.  9. 12. 15. 16. 20. 25.]\n",
      " [ 1.  6.  7.  8. 36. 42. 48. 49. 56. 64.]]\n"
     ]
    }
   ],
   "source": [
    "#P149  PolynomialFeatures() function:\n",
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "X=np.arange(9).reshape(3,3)\n",
    "poly=PolynomialFeatures(degree=2)\n",
    "print(X)\n",
    "print(poly.fit_transform(X))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1.38340578]\n",
      " [ 2.22189802]\n",
      " [ 3.6053038 ]\n",
      " [-1.38340578]\n",
      " [-2.22189802]\n",
      " [-3.6053038 ]]\n"
     ]
    }
   ],
   "source": [
    "#P151 PCA\n",
    "from sklearn.decomposition import PCA\n",
    "import numpy as np\n",
    "X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])\n",
    "pca = PCA(n_components=1)\n",
    "pca.fit(X)\n",
    "print(pca.transform(X))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
